package com.emm.yixun.mobile.fragment;

import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.util.Log;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnKeyListener;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.alibaba.fastjson.JSONObject;
import com.emm.yixun.mobile.R;
import com.emm.yixun.mobile.adapter.AnalysisMenuAdapter;
import com.emm.yixun.mobile.adapter.TimeLabelAdapter;
import com.emm.yixun.mobile.application.EmmApplication;
import com.emm.yixun.mobile.base.BaseActivity;
import com.emm.yixun.mobile.model.GetTimeConditionAnalysis;
import com.emm.yixun.mobile.model.MenuList;
import com.emm.yixun.mobile.model.TimeModel;
import com.emm.yixun.mobile.ui.analysis.AnalysisListViewActivity;
import com.emm.yixun.mobile.ui.analysis.CalculatePriceAnalysisActivity;
import com.emm.yixun.mobile.ui.analysis.CustomerAnalysisActivity;
import com.emm.yixun.mobile.ui.analysis.DealHousingActivity;
import com.emm.yixun.mobile.ui.analysis.HousingTypeAnalySisActivity;
import com.emm.yixun.mobile.ui.analysis.NotSignedBackActivity;
import com.emm.yixun.mobile.ui.analysis.SalesTargetActivity;
import com.emm.yixun.mobile.ui.analysis.TimeAnalysisActivity;
import com.eroad.product.tools.MyGridView;
import com.eroad.product.tools.MySeekBar;
import com.eroad.product.tools.PickerView;
import com.eroad.product.tools.PickerView.onSelectListener;
import com.eroad.product.tools.PopuContent;
import com.eroad.product.tools.Time_SelectPicPopupWindow;
import com.loopj.android.http.AsyncHttpClient;
import com.loopj.android.http.AsyncHttpResponseHandler;
import com.loopj.android.http.RequestParams;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import xf.tools.Loading;

/**
 *
 * <p>
 * <b>Title：</b> 分析模块，优化版
 * </p>
 * <p>
 * <b>Description：</b>
 * </p>
 *
 *
 * @author tangxin
 * @date 2017年1月4日 下午6:15:45
 */
public class AnalysisOptimizationFragment extends Fragment {

	private static final String TAG = "AnalysisOptimization";

	private FragmentActivity root = null;

	/** 九宫格菜单 */
	private MyGridView menu_gridview;

	private ArrayList<MenuList> menulist = new ArrayList<MenuList>();

	/** 菜单图片 */
	private int[] img = new int[] { R.drawable.fx_ico5, R.drawable.fx_ico6, R.drawable.fx_ico7, R.drawable.fx_ico8,
			R.drawable.analysis_06, R.drawable.analysis_07, R.drawable.analysis_08, R.drawable.analysis_09,
			R.drawable.analysis_10 };

	/** 菜单标题 */
	private String[] title = new String[] { "客户分析", "已签约未回款", "工作量统计", "销售指标", "成交房产", "存量时间", "算价分析", "成交房源", "存量房源" };

	/** 菜单适配器 */
	private AnalysisMenuAdapter menuAdapter;

	/** 年指标进度1 */
	private MySeekBar seekbar_index1;

	/** 年指标进度2 */
	private MySeekBar seekbar_index2;

	/** 年指标进度3 */
	private MySeekBar seekbar_index3;

	/** 月指标进度1 */
	private MySeekBar month_seekbar_index1;

	/** 月指标进度2 */
	private MySeekBar month_seekbar_index2;

	/** 月指标进度3 */
	private MySeekBar month_seekbar_index3;

	/** 打开选择 */
	private LinearLayout open_selection;

	/** 选中类型 默认今天 */
	private TextView selection_type;

	/** 截图分享的布局 */
	private LinearLayout share_layout;

	/** 选择时间弹出框 */
	PopupWindow popu_time;

	View view;

	/** 时间，指标列表 */
	MyGridView gridView_time, gridView_index;

	/** 起始时间，结束时间 */
	TextView time_start, time_end;

	/** 指标开始时间 */
	TextView index_time_start;

	/** 指标结束时间 */
	TextView index_time_ed;

	/** 年指标 */
	TextView year_index_time_start;

	/** 重置 */
	TextView reset;

	/** 确定 */
	TextView sure;

	/** 成绩时间选择数据 */
	ArrayList<TimeModel> listtime;

	/** 月指标选择数据 */
	ArrayList<TimeModel> listindex;

	/** 成绩时间选择适配器 */
	TimeLabelAdapter adapter_time;

	/** 月指标选择适配器 */
	TimeLabelAdapter adapter_index;

	/* ---公用选择框--- */
	PopupWindow popu;

	/** 选中内容 */
	String selectName;

	/** 选中下标 */
	int SelectID;

	/** 选项数据 */
	ArrayList<String> listname;

	/* ---公用选择框--- */

	/** 时间格式 */
	DateFormat fmt;

	/** 当前年份 */
	String time;

	/** 选中的时间ID */
	private String time_id = "1";
	private String time_id2 = "1";

	/** 选中的指标ID */
	private String index_id = "1";
	private String index_id2 = "1";

	/** 自定义时间控件 */
	private Time_SelectPicPopupWindow time_SelectPicPopupWindow;

	/** 选择时间的view */
	private TextView time_textview;

	/** 是否选择时间（false为手填） */
	private boolean IsSelectTime = true;
	private boolean IsSelectTime2 = true;

	/** 是否选择月指标（false为手填） */
	private boolean IsSelectIndex = true;
	private boolean IsSelectIndex2 = true;

	/** 开始时间 */
	private String Time_start_str = "";
	private String Time_start_str2 = "";

	/** 结束时间 */
	private String Time_end_str = "";
	private String Time_end_str2 = "";

	/** 月指标开始时间 */
	private String Index_start_str = "";
	private String Index_start_str2 = "";

	/** 月指标结束时间 */
	private String Index_end_str = "";
	private String Index_end_str2 = "";

	/** 年指标选择结果 */
	private String Index_year_str = "";
	private String Index_year_str2 = "";

	/** 来电数量 */
	private TextView call_num;

	/** 来电有效数量 */
	private TextView valid_call;

	/** 来访数量 */
	private TextView visit_num;

	/** 新客来访数量 */
	private TextView newvisit_num;

	/** 老客来访数量 */
	private TextView oldvisit_num;

	/** 认筹数量 */
	private TextView from_num;

	/** 认购数量 */
	private TextView subscribe_Num;

	/** 认购金额 */
	private TextView subscribe_Amount;

	/** 签约数量 */
	private TextView signed_num;

	/** 签约金额 */
	private TextView signed_amount;

	/** 回款金额 */
	private TextView payment_amount;

	/** 月指标完成率 */
	private TextView monthlySalesRate;

	/** 月销售完成量 / 指标 */
	private TextView monthlySalesTarget;

	/** 月回款指标完成率 */
	private TextView monthlyPaymentRate;

	/** 月回款完成量 / 指标 */
	private TextView monthlyPaymentTarget;

	/** 月综合指标完成率 */
	private TextView monthlyGeneralRate;

	/** 月综合指标完成量 / 指标 */
	private TextView monthlyGeneralTarget;

	/** 年销售指标完成率 */
	private TextView yearSalesRate;

	/** 年销售完成量 / 指标 */
	private TextView yearSalesTarget;

	/** 年回款指标完成率 */
	private TextView yearPaymentRate;

	/** 年回款完成量 / 指标 */
	private TextView yearPaymentTarget;

	/** 年综合指标完成率 */
	private TextView yearGeneralRate;

	/** 年综合指标完成量 / 指标 */
	private TextView yearGeneralTarget;

	/** 当前筛选弹出框是否已打开 默认关闭 */
	private boolean IsOpenPopu = false;

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
		return inflater.inflate(R.layout.analysis_optimization_fragment, null);
	}

	@Override
	public void onActivityCreated(Bundle savedInstanceState) {
		super.onActivityCreated(savedInstanceState);
		root = getActivity();

		Initdate();

		InitView();

		InitBtn();

		SetData2Adapter(menulist);

		DefaultGetTimeConditionAnalysis();
	}

	/**
	 * <p>
	 * <b>Title：</b>根据ID绑定view
	 * </p>
	 * <p>
	 * <b>Description：</b>
	 * </p>
	 *
	 * @author tangxin
	 * @date 2017年1月10日 下午5:47:28
	 */
	private void InitView() {
		BaseActivity.SetViewHeight((RelativeLayout) root.findViewById(R.id.analysis_include_optimization).findViewById(
				R.id.main_head_top_rela));// 更改relativelayout的高度
		menu_gridview = (MyGridView) root.findViewById(R.id.menu_gridview);
		seekbar_index1 = (MySeekBar) root.findViewById(R.id.seekbar_index1);
		seekbar_index2 = (MySeekBar) root.findViewById(R.id.seekbar_index2);
		seekbar_index3 = (MySeekBar) root.findViewById(R.id.seekbar_index3);
		month_seekbar_index1 = (MySeekBar) root.findViewById(R.id.month_seekbar_index1);
		month_seekbar_index2 = (MySeekBar) root.findViewById(R.id.month_seekbar_index2);
		month_seekbar_index3 = (MySeekBar) root.findViewById(R.id.month_seekbar_index3);
		open_selection = (LinearLayout) root.findViewById(R.id.open_selection);
		selection_type = (TextView) root.findViewById(R.id.selection_type);
		share_layout = (LinearLayout) root.findViewById(R.id.share_layout);
		call_num = (TextView) root.findViewById(R.id.Call_num);
		valid_call = (TextView) root.findViewById(R.id.valid_call);
		visit_num = (TextView) root.findViewById(R.id.visit_num);
		newvisit_num = (TextView) root.findViewById(R.id.newvisit_num);
		oldvisit_num = (TextView) root.findViewById(R.id.oldvisit_num);
		from_num = (TextView) root.findViewById(R.id.from_num);
		subscribe_Num = (TextView) root.findViewById(R.id.subscribe_Num);
		subscribe_Amount = (TextView) root.findViewById(R.id.subscribe_Amount);
		signed_num = (TextView) root.findViewById(R.id.signed_num);
		signed_amount = (TextView) root.findViewById(R.id.signed_amount);
		payment_amount = (TextView) root.findViewById(R.id.payment_amount);
		monthlySalesRate = (TextView) root.findViewById(R.id.monthlySalesRate);
		monthlySalesTarget = (TextView) root.findViewById(R.id.monthlySalesTarget);
		monthlyPaymentRate = (TextView) root.findViewById(R.id.monthlyPaymentRate);
		monthlyPaymentTarget = (TextView) root.findViewById(R.id.monthlyPaymentTarget);
		monthlyGeneralRate = (TextView) root.findViewById(R.id.monthlyGeneralRate);
		monthlyGeneralTarget = (TextView) root.findViewById(R.id.monthlyGeneralTarget);
		yearSalesRate = (TextView) root.findViewById(R.id.yearSalesRate);
		yearSalesTarget = (TextView) root.findViewById(R.id.yearSalesTarget);
		yearPaymentRate = (TextView) root.findViewById(R.id.yearPaymentRate);
		yearPaymentTarget = (TextView) root.findViewById(R.id.yearPaymentTarget);
		yearGeneralRate = (TextView) root.findViewById(R.id.yearGeneralRate);
		yearGeneralTarget = (TextView) root.findViewById(R.id.yearGeneralTarget);

		// 默认状态
		selection_type.setText("今日成绩 + 本月指标 + " + time + "年指标");
	}

	@Override
	public void onHiddenChanged(boolean hidden) {
		if (hidden) {
			Log.v(TAG, "Fragment的onPause");
		} else {
			Log.v(TAG, "Fragment的onResume");
			DefaultGetTimeConditionAnalysis();
		}
	}

	/**
	 * <p>
	 * <b>Title：</b> 监听控件点击事件
	 * </p>
	 * <p>
	 * <b>Description：</b>
	 * </p>
	 *
	 * @author tangxin
	 * @date 2017年1月10日 下午5:49:30
	 */
	private void InitBtn() {
		// 打开条件筛选
		open_selection.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				SettimePopu();
			}
		});

		// 打开对应的分析界面
		menu_gridview.setOnItemClickListener(new OnItemClickListener() {
			@Override
			public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
				OpenActivity(position);
			}
		});
	}

	/**
	 * <p>
	 * <b>Title：</b> 初始化菜单数据
	 * </p>
	 * <p>
	 * <b>Description：</b>
	 * </p>
	 *
	 * @author tangxin
	 * @date 2017年1月5日 下午12:51:24
	 */
	private void Initdate() {

		// 当前年份
		fmt = new SimpleDateFormat("yyyy");
		time = fmt.format(EmmApplication.geTime());
		selectName = time + "年";
		Index_year_str2 = selectName;

		// 底部菜单数据
		for (int i = 0; i < img.length; i++) {
			MenuList mitem = new MenuList();
			mitem.setImg_id(img[i]);
			mitem.setTitle(title[i]);
			menulist.add(mitem);
		}

		// 月指标选择数据
		listtime = new ArrayList<TimeModel>();
		TimeModel model = new TimeModel("今天", true, "1");
		listtime.add(model);
		TimeModel model2 = new TimeModel("昨天", false, "2");
		listtime.add(model2);
		TimeModel model3 = new TimeModel("本周", false, "3");
		listtime.add(model3);
		TimeModel model4 = new TimeModel("上周", false, "4");
		listtime.add(model4);
		TimeModel model5 = new TimeModel("本月", false, "5");
		listtime.add(model5);
		TimeModel model6 = new TimeModel("上月", false, "6");
		listtime.add(model6);
		TimeModel model7 = new TimeModel("近三月", false, "7");
		listtime.add(model7);
		TimeModel model8 = new TimeModel("今年", false, "8");
		listtime.add(model8);

		// 年指标选择数据
		listindex = new ArrayList<TimeModel>();
		TimeModel a = new TimeModel("本月", true, "1");
		listindex.add(a);
		TimeModel b = new TimeModel("上月", false, "2");
		listindex.add(b);
		TimeModel c = new TimeModel("近三月", false, "3");
		listindex.add(c);
		TimeModel d = new TimeModel("近六月", false, "4");
		listindex.add(d);
	}

	/**
	 * <p>
	 * <b>Title：</b> 设置数据到适配器并展示菜单
	 * </p>
	 * <p>
	 * <b>Description：</b>
	 * </p>
	 *
	 * @param list
	 * @author tangxin
	 * @date 2017年1月5日 下午2:16:51
	 */
	private void SetData2Adapter(ArrayList<MenuList> list) {
		if (null == menuAdapter) {
			menuAdapter = new AnalysisMenuAdapter(list, root);
			menu_gridview.setAdapter(menuAdapter);
		} else {
			menuAdapter.Setdata(list);
		}
	}

	/**
	 * <p>
	 * <b>Title：</b>分享 share_layout 布局内的数据，以截图方式
	 * </p>
	 * <p>
	 * <b>Description：</b>
	 * </p>
	 *
	 * @author tangxin
	 * @date 2017年1月10日 下午3:32:36
	 */
	public void ShareBitmap() {
		// 截图分享
		Intent shareIntent = new Intent();
		shareIntent.setAction(Intent.ACTION_SEND);
		File f = getLinearBitmap(share_layout);
		if (f != null && f.exists() && f.isFile()) {
			Uri u = Uri.fromFile(f);
			shareIntent.putExtra(Intent.EXTRA_STREAM, u);
		}
		shareIntent.setType("image/*");
		shareIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
		root.startActivity(Intent.createChooser(shareIntent, "分享到:"));
	}

	/**
	 * 
	 * <p>
	 * <b>Title：</b> 截取linearLayout
	 * </p>
	 * <p>
	 * <b>Description：</b>
	 * </p>
	 * 
	 * @param linearLayout
	 *            需要截取的对象
	 * @return
	 * @author tangxin
	 * @date 2016年12月7日 下午2:13:26
	 */
	public File getLinearBitmap(LinearLayout linearLayout) {
		File picpath = null;
		try {
			picpath = File.createTempFile(EmmApplication.geTimes(), ".png", new File(EmmApplication.getDatePatch()));
		} catch (IOException e) {
			e.printStackTrace();
		}
		Bitmap bitmap;

		linearLayout.measure(0, 0);
		// 获取组件的高度
		int h = linearLayout.getMeasuredHeight();

		Log.d(TAG, "实际高度:" + h);
		Log.d(TAG, " 高度:" + linearLayout.getHeight());
		// 创建对应大小的bitmap
		bitmap = Bitmap.createBitmap(linearLayout.getWidth(), h, Bitmap.Config.ARGB_8888);
		final Canvas canvas = new Canvas(bitmap);
		linearLayout.draw(canvas);
		// 输出
		FileOutputStream out = null;
		try {
			out = new FileOutputStream(picpath.toString());
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}
		try {
			if (null != out) {
				bitmap.compress(Bitmap.CompressFormat.PNG, 100, out);
				out.flush();
				out.close();
			}
		} catch (IOException e) {
		}
		return picpath;
	}

	/**
	 * <p>
	 * <b>Title：</b> 根据点击的，打开对应的activity
	 * </p>
	 * <p>
	 * <b>Description：</b><br>
	 * 0:客户分析<br>
	 * 1:已签约未回款<br>
	 * 2:工作量统计<br>
	 * 3:销售指标<br>
	 * 4:成交房产<br>
	 * 5:存量时间<br>
	 * 6:算价分析<br>
	 * 7:成交房源<br>
	 * 8:存量房源
	 * </p>
	 *
	 * @param position
	 * @author tangxin
	 * @date 2017年1月5日 下午3:42:59
	 */
	private void OpenActivity(int position) {
		Intent intent = new Intent();
		switch (position) {
		case 0:
			intent.setClass(root, CustomerAnalysisActivity.class);
			break;
		case 1:
			intent.setClass(root, NotSignedBackActivity.class);
			break;
		case 2:
			intent.setClass(root, AnalysisListViewActivity.class);
			break;
		case 3:
			intent.setClass(root, SalesTargetActivity.class);
			break;
		case 4:
			intent.setClass(root, HousingTypeAnalySisActivity.class);
			break;
		case 5:
			intent.setClass(root, TimeAnalysisActivity.class);
			break;
		case 6:
			intent.setClass(root, CalculatePriceAnalysisActivity.class);
			break;
		case 7:
			intent.setClass(root, DealHousingActivity.class);
			intent.putExtra("TypeHousing", "1");
			break;
		case 8:
			intent.setClass(root, DealHousingActivity.class);
			intent.putExtra("TypeHousing", "2");
			break;
		default:
			break;
		}
		startActivity(intent);
	}

	/**
	 *
	 * <p>
	 * Title:项目日报筛选框
	 * </p>
	 * <p>
	 * Description:
	 * </p>
	 *
	 * @author zhaofei
	 * @date 2017年1月6日 下午4:50:29
	 */
	public void SettimePopu() {
		view = LayoutInflater.from(root).inflate(R.layout.analysis_optimization_popu, null);
		popu_time = new PopupWindow(view, android.support.v4.view.ViewPager.LayoutParams.FILL_PARENT,
				android.support.v4.view.ViewPager.LayoutParams.FILL_PARENT);
		popu_time.setFocusable(true);// 先获取一次焦点，不然会被mainactivity的back监听事件拦截back按钮的触发
		popu_time.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
		popu_time.showAtLocation(view, Gravity.BOTTOM, 0, 0);
		popu_time.showAsDropDown(view, 0, 0);
		IsOpenPopu = true;
		popu_time.setFocusable(true);
		popu_time.setOutsideTouchable(true);
		view.setFocusable(true);
		view.setFocusableInTouchMode(true);
		view.setOnKeyListener(new OnKeyListener() {
			@Override
			public boolean onKey(View v, int keyCode, KeyEvent event) {
				if (keyCode == KeyEvent.KEYCODE_BACK) {
					popu_time.dismiss();
					IsOpenPopu = false;
				}
				return false;
			}
		});
		view.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View arg0) {
				popu_time.dismiss();
				IsOpenPopu = false;
			}
		});

		// 初始化年指标选项数据
		final List<String> list = new ArrayList<String>();
		int year = Integer.valueOf(time).intValue();
		for (int i = 0; i < 2000; i++) {// 当前年份向前推50年
			list.add((3500 - i) + "年");
		}

		// 模拟顶部分享按钮
		TextView share_gone_btn = (TextView) view.findViewById(R.id.share_gone_btn);

		time_start = (TextView) view.findViewById(R.id.tiem_start);
		time_end = (TextView) view.findViewById(R.id.tiem_end);
		reset = (TextView) view.findViewById(R.id.reset);
		sure = (TextView) view.findViewById(R.id.sure);
		index_time_start = (TextView) view.findViewById(R.id.index_time_start);
		index_time_ed = (TextView) view.findViewById(R.id.index_time_end);
		year_index_time_start = (TextView) view.findViewById(R.id.year_index_time_start);
		gridView_time = (MyGridView) view.findViewById(R.id.time_gridview);
		gridView_index = (MyGridView) view.findViewById(R.id.time_gridview2);
		LinearLayout bg_popu_layout = (LinearLayout) view.findViewById(R.id.bg_popu_layout);

		adapter_time = new TimeLabelAdapter(listtime);
		gridView_time.setAdapter(adapter_time);
		adapter_index = new TimeLabelAdapter(listindex);
		gridView_index.setAdapter(adapter_index);

		time_start.setText(Time_start_str);
		time_end.setText(Time_end_str);
		index_time_start.setText(Index_start_str);
		index_time_ed.setText(Index_end_str);

		// 初始化显示状态，显示上次操作保留的状态（第一次即显示默认）
		if (IsSelectTime) {
			adapter_time.SelectPosition(Integer.valueOf(time_id).intValue() - 1);
		} else {
			adapter_time.SelectPosition(-1);
			SetBackground(2);
		}
		if (IsSelectIndex) {
			adapter_index.SelectPosition(Integer.valueOf(index_id).intValue() - 1);
		} else {
			adapter_index.SelectPosition(-1);
			SetIndexBackground(2);
		}

		share_gone_btn.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				// 截图分享
				ShareBitmap();
			}
		});

		bg_popu_layout.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
			}
		});

		reset.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				// 重置成绩所有选择状态
				SetBackground(1);
				time_start.setText("");
				time_end.setText("");
				adapter_time.SelectPosition(0);
				time_id2 = listtime.get(0).getId();

				// 重置月指标所有选择状态
				SetIndexBackground(1);
				index_time_start.setText("");
				index_time_ed.setText("");
				adapter_index.SelectPosition(0);
				index_id2 = listindex.get(0).getId();

				// 重置年指标所有选择状态
				year_index_time_start.setText(time + "年");
				Index_year_str2 = time;
				selectName = time + "年";

				// 重置所有时间项
				Time_start_str2 = "";
				Time_end_str2 = "";
				Index_start_str2 = "";
				Index_end_str2 = "";

			}
		});

		sure.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {

				Map<String, String> map = new HashMap<String, String>();

				if (IsSelectTime2) {// 是否手动填写时间
					map.put("gradesTimeType", time_id2);// 成绩时间类型
				} else {
					if (EmmApplication.isNull(Time_start_str2)) {
						map.put("gradesStartTime", EmmApplication.replaceTime(Time_start_str2));// 成绩开始时间
					} else {
						EmmApplication.Ts("请选择成绩开始时间");
						return;
					}
					if (EmmApplication.isNull(Time_end_str2)) {
						map.put("gradesEndTime", EmmApplication.replaceTime(Time_end_str2));// 成绩结束时间
					} else {
						EmmApplication.Ts("请选择成绩结束时间");
						return;
					}
				}

				if (IsSelectIndex2) {// 是否手动填写月指标
					map.put("monthlyType", index_id2);// 月指标类型
				} else {
					if (EmmApplication.isNull(Index_start_str2)) {
						map.put("monthlyStartTime", EmmApplication.replaceTimeDay(Index_start_str2));// 月指标开始时间
					} else {
						EmmApplication.Ts("请选择月指标开始时间");
						return;
					}
					if (EmmApplication.isNull(Index_end_str2)) {
						map.put("monthlyEndTime", EmmApplication.replaceTimeDay(Index_end_str2));// 月指标结束时间
					} else {
						EmmApplication.Ts("请选择月指标结束时间");
						return;
					}
				}

				if (EmmApplication.isNull(year_index_time_start.getText().toString().trim())) {// 年指标
					map.put("yearTime", EmmApplication.replace("年", "", year_index_time_start.getText().toString().trim()));// 年指标时间
				} else {
					EmmApplication.Ts("请选择年指标时间");
				}

				popu_time.dismiss();
				IsOpenPopu = false;
				time_id = time_id2;
				index_id = index_id2;
				IsSelectTime = IsSelectTime2;
				IsSelectIndex = IsSelectIndex2;
				Time_start_str = Time_start_str2;
				Time_end_str = Time_end_str2;
				Index_start_str = Index_start_str2;
				Index_end_str = Index_end_str2;
				selection_type.setText((IsSelectTime2 ? listtime.get(Integer.valueOf(time_id2).intValue() - 1)
						.getName() : (map.get("gradesStartTime") + " - " + map.get("gradesEndTime")))
						+ "成绩 + "
						+ (IsSelectIndex2 ? listindex.get(Integer.valueOf(index_id2).intValue() - 1).getName() : (map
								.get("monthlyStartTime") + " - " + map.get("monthlyEndTime")))
						+ "指标 + "
						+ map.get("yearTime") + "指标");

				GetTimeConditionAnalysis(map);
			}
		});

		gridView_time.setOnItemClickListener(new OnItemClickListener() {
			@Override
			public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

				// 重置手动填写时间项选择状态
				SetBackground(1);

				adapter_time.SelectPosition(position);
				time_id2 = listtime.get(position).getId();// 获取选择的时间ID
				Log.v(TAG, "time_id:" + time_id2);

			}
		});
		gridView_index.setOnItemClickListener(new OnItemClickListener() {
			@Override
			public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

				// 重置手动填写时间项选择状态
				SetIndexBackground(1);

				adapter_index.SelectPosition(position);
				index_id2 = listindex.get(position).getId();// 获取选择的指标ID
				Log.v(TAG, "index_id:" + index_id2);

			}
		});

		time_start.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				time_textview = time_start;
				time_SelectPicPopupWindow = new Time_SelectPicPopupWindow(root, keyListener, 0, GetDate(time_start, 0));
				time_SelectPicPopupWindow.showAtLocation(open_selection, Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0,
						0);
			}
		});

		time_end.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				if (EmmApplication.isNull(time_start.getText().toString().trim())) {
					time_textview = time_end;
					time_SelectPicPopupWindow = new Time_SelectPicPopupWindow(root, keyListener, 0, GetDate(
							EmmApplication.isNull(time_end.getText().toString().trim()) ? time_end : time_start,
							EmmApplication.isNull(time_end.getText().toString().trim()) ? 0 : 1));
					time_SelectPicPopupWindow.showAtLocation(open_selection,
							Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0, 0);
				} else {
					EmmApplication.Ts("请先选择开始时间");
				}
			}
		});

		index_time_start.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				time_textview = index_time_start;
				time_SelectPicPopupWindow = new Time_SelectPicPopupWindow(root, keyListener, EmmApplication.monthCode,
						GetDate(index_time_start, 6));
				time_SelectPicPopupWindow.showAtLocation(open_selection, Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0,
						0);
			}
		});

		index_time_ed.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				if (EmmApplication.isNull(index_time_start.getText().toString().trim())) {
					time_textview = index_time_ed;
					time_SelectPicPopupWindow = new Time_SelectPicPopupWindow(root, keyListener, EmmApplication.monthCode,
							GetDate(EmmApplication.isNull(index_time_ed.getText().toString().trim()) ? index_time_ed
									: index_time_start,
									EmmApplication.isNull(index_time_ed.getText().toString().trim()) ? 6 : 7));
					time_SelectPicPopupWindow.showAtLocation(open_selection,
							Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0, 0);
				} else {
					EmmApplication.Ts("请先选择开始时间");
				}
			}
		});
		Index_year_str = Index_year_str2;
		year_index_time_start.setText(EmmApplication.isNull(Index_year_str2) ? (EmmApplication.replace("年", "",
				Index_year_str) + "年") : (time + "年"));
		year_index_time_start.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				SetzpPopu(list, "年指标", year_index_time_start);
			}
		});

	}

	/**
	 * <p>
	 * <b>Title：</b> 获取时间
	 * </p>
	 * <p>
	 * <b>Description：</b> 获取某输入框显示的时间，并格式化为date类型返回
	 * </p>
	 *
	 * @param view
	 *            输入框
	 * @param type
	 *            成绩时间 1往后推一天，0不做处理 月指标 6不做处理 7往后推一个月
	 * @return
	 * @author tangxin
	 * @date 2017年1月9日14:13:39
	 */
	private Date GetDate(TextView view, int type) {
		if (null != view.getText().toString().trim() && !"".equals(view.getText().toString().trim())
				&& !"null".equals(view.getText().toString().trim())) {
			DateFormat fmt = null;
			if (7 == type || 6 == type) {
				fmt = new SimpleDateFormat("yyyy年MM月");
			} else {
				fmt = new SimpleDateFormat("yyyy年MM月dd日");
			}
			Date date = null;
			try {
				String str = view.getText().toString().trim();
				Log.v(TAG, "view.getText().toString().trim()->" + str);
				date = fmt.parse(str);
			} catch (ParseException e) {
				date = new Date(System.currentTimeMillis());
				e.printStackTrace();
			}
			if (1 == type) {
				Calendar calendar = new GregorianCalendar();
				calendar.setTime(date);
				calendar.add(calendar.DATE, 1);// 把日期往后增加一天.整数往后推,负数往前移动
				date = calendar.getTime(); // 这个时间就是日期往后推一天的结果
			} else if (7 == type) {
				Calendar calendar = new GregorianCalendar();
				calendar.setTime(date);
				calendar.add(calendar.MONTH, 1);// 把日期往后增加一月.整数往后推,负数往前移动
				date = calendar.getTime();
			}
			return date;
		} else {
			return new Date(System.currentTimeMillis());
		}
	}

	/**
	 * 自定义时间选择控件的监听事件
	 */
	OnClickListener keyListener = new OnClickListener() {
		@Override
		public void onClick(View v) {
			switch (v.getId()) {
			case R.id.imageView1:
				time_SelectPicPopupWindow.dismiss();
				time_SelectPicPopupWindow.Aprils.clear();
				time_SelectPicPopupWindow.Years.clear();
				time_SelectPicPopupWindow.Days.clear();

				SimpleDateFormat formats = new SimpleDateFormat("yyyy年MM月dd日");
				Calendar c = Calendar.getInstance();
				try {
					// 得到时间控件选中的内容
					c.setTime(formats.parse(time_SelectPicPopupWindow.getLanguage()
							+ time_SelectPicPopupWindow.getType_One() + time_SelectPicPopupWindow.getType()));
				} catch (ParseException e) {
					e.printStackTrace();
				}

				Date endDate = c.getTime();
				String str = formats.format(endDate);
				Log.w(TAG, "str:" + str);

				// 设定时间的模板
				SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日");
				SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy年MM月");
				if (time_end == time_textview || index_time_ed == time_textview) {// 结束时间对比开始时间
					// 得到指定模范的时间
					Date time1 = null;
					Date time2 = null;
					try {
						if (time_end == time_textview) {// 开始时间
							time1 = sdf.parse(time_start.getText().toString().trim());
						} else {
							time1 = sdf2.parse(index_time_start.getText().toString().trim());
						}
					} catch (ParseException e) {
						e.printStackTrace();
					}
					try {
						if (time_end == time_textview) {
							time2 = sdf.parse(str);
						} else {
							time2 = sdf2.parse(str);
						}
					} catch (ParseException e) {
						e.printStackTrace();
					}
					if (null != time1) {
						// 比较
						if (((time1.getTime() - time2.getTime()) / (24 * 3600 * 1000)) > 0) {
							// 结束时间早于开始时间时,提示
							PopuContent.poPu(root, "结束时间不能早于开始时间", false, 1);
							if (index_time_ed == time_textview) {
								str = sdf2
										.format(GetDate(time_end == time_textview ? time_start : index_time_start, 6));
							} else {
								str = formats.format(GetDate(time_end == time_textview ? time_start : index_time_start,
										0));
							}
						} else {
							// 符合情景，显示正常,不做处理
							if (index_time_ed == time_textview) {
								str = sdf2.format(endDate);
							}
						}
					} else {
						if (index_time_ed == time_textview) {
							str = sdf2.format(endDate);
						}
					}
				} else {// 开始时间对比结束时间
					Date time1 = null;
					try {
						if (time_start == time_textview) {// 结束时间
							time1 = sdf.parse(time_end.getText().toString().trim());
						} else {
							time1 = sdf2.parse(index_time_ed.getText().toString().trim());
						}

					} catch (ParseException e) {
						e.printStackTrace();
					}
					Date time2 = null;
					try {
						if (time_start == time_textview) {
							time2 = sdf.parse(str);
						} else {
							time2 = sdf2.parse(str);
						}
					} catch (ParseException e) {
						e.printStackTrace();
					}
					if (null != time1) {
						if (((time1.getTime() - time2.getTime()) / (24 * 3600 * 1000)) >= 0) {
							// 符合情景，显示正常,不做处理
							if (index_time_start == time_textview) {
								str = sdf2.format(endDate);
							}
						} else {
							// 结束时间早于开始时间时,提示
							PopuContent.poPu(root, "开始时间不能晚于结束时间", false, 1);
							if (index_time_start == time_textview) {
								str = sdf2.format(GetDate(time_start == time_textview ? time_end : index_time_ed, 6));
							} else {
								str = formats
										.format(GetDate(time_start == time_textview ? time_end : index_time_ed, 0));
							}
						}
					} else {
						if (index_time_start == time_textview) {
							str = sdf2.format(endDate);
						}
					}
				}

				// 给对应的选择类型赋值
				if (time_start == time_textview) {
					Time_start_str2 = str;
				} else if (time_end == time_textview) {
					Time_end_str2 = str;
				} else if (index_time_start == time_textview) {
					Index_start_str2 = str;
				} else if (index_time_ed == time_textview) {
					Index_end_str2 = str;
				}

				time_textview.setText(str);

				// 重置时间选项（无选择状态）
				if (time_end == time_textview || time_start == time_textview) {
					adapter_time.SelectPosition(-1);

					SetBackground(2);
				}
				if (index_time_ed == time_textview || index_time_start == time_textview) {
					adapter_index.SelectPosition(-1);

					SetIndexBackground(2);
				}

				break;
			default:
				break;
			}
		}
	};

	/**
	 * <p>
	 * <b>Title：</b> 根据更改状态，更新显示样式
	 * </p>
	 * <p>
	 * <b>Description：</b>
	 * </p>
	 *
	 * @param type
	 *            1灰色 2选择
	 * @author tangxin
	 * @date 2017年1月9日 下午2:05:18
	 */
	private void SetBackground(int type) {
		if (1 == type) {
			IsSelectTime2 = true;
		} else {
			IsSelectTime2 = false;
		}
		time_start.setBackgroundResource(type == 1 ? R.drawable.shape_analysis_time : R.drawable.shape_analysis_time2);
		time_end.setBackgroundResource(type == 1 ? R.drawable.shape_analysis_time : R.drawable.shape_analysis_time2);
		time_start.setTextColor(Color.parseColor(type == 1 ? "#5A5A5A" : "#f87242"));
		time_end.setTextColor(Color.parseColor(type == 1 ? "#5A5A5A" : "#f87242"));
	}

	/**
	 * <p>
	 * <b>Title：</b> 根据更改状态，更新月指标显示样式
	 * </p>
	 * <p>
	 * <b>Description：</b>
	 * </p>
	 *
	 * @param type
	 *            1灰色 2选择
	 * @author tangxin
	 * @date 2017年1月9日 下午6:17:10
	 */
	private void SetIndexBackground(int type) {
		if (1 == type) {
			IsSelectIndex2 = true;
		} else {
			IsSelectIndex2 = false;
		}
		index_time_start.setBackgroundResource(type == 1 ? R.drawable.shape_analysis_time
				: R.drawable.shape_analysis_time2);
		index_time_ed.setBackgroundResource(type == 1 ? R.drawable.shape_analysis_time
				: R.drawable.shape_analysis_time2);
		index_time_start.setTextColor(Color.parseColor(type == 1 ? "#5A5A5A" : "#f87242"));
		index_time_ed.setTextColor(Color.parseColor(type == 1 ? "#5A5A5A" : "#f87242"));
	}

	/**
	 *
	 * <p>
	 * <b>Title：</b> 选项框
	 * </p>
	 * <p>
	 * <b>Description：</b>
	 * </p>
	 *
	 * @param listname
	 *            选项内容list
	 * @param title
	 *            选项名
	 * @param ed
	 *            选择结果显示的edittext
	 * @author tangxin
	 * @date 2016年12月6日 下午5:44:05
	 */
	public void SetzpPopu(final List<String> listname, String title, final TextView ed) {
		view = LayoutInflater.from(root).inflate(R.layout.popu_zp, null);
		popu = new PopupWindow(view, android.support.v4.view.ViewPager.LayoutParams.FILL_PARENT,
				android.support.v4.view.ViewPager.LayoutParams.FILL_PARENT);
		popu.setFocusable(true);
		popu.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
		popu.showAtLocation(view, Gravity.BOTTOM, 0, 0);
		popu.showAsDropDown(view, 0, 0);
		popu.setFocusable(true);
		popu.setOutsideTouchable(true);
		view.setFocusable(true);
		view.setFocusableInTouchMode(true);
		view.setOnKeyListener(new OnKeyListener() {
			@Override
			public boolean onKey(View v, int keyCode, KeyEvent event) {
				if (keyCode == KeyEvent.KEYCODE_BACK) {
					popu.dismiss();
					EmmApplication.setLog(root);
				}
				return false;
			}
		});
		view.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View arg0) {
				popu.dismiss();
				EmmApplication.setLog(root);
			}
		});

		PickerView select_pick = (PickerView) view.findViewById(R.id.select_pick);
		TextView shuerbtn = (TextView) view.findViewById(R.id.shuerbtn);
		RelativeLayout relative_all = (RelativeLayout) view.findViewById(R.id.relative_all);
		ImageView dis_btn = (ImageView) view.findViewById(R.id.dis_btn);

		// 取消
		dis_btn.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				popu.dismiss();
				EmmApplication.setLog(root);
			}
		});
		TextView title_select = (TextView) view.findViewById(R.id.title_select);
		title_select.setText(title);

		// 设置数据到滑动控件
		select_pick.setData(listname);

		// 默认选中
		select_pick.setSelected(0);
		selectName = listname.get(0);

		for (int i = 0; i < listname.size(); i++) {
			if (EmmApplication.isNull(ed.getText().toString().trim())) {
				if (listname.get(i).equals(ed.getText().toString().trim())) {
					// 若存在已选择的，覆盖默认选中的
					select_pick.setSelected(i);
					selectName = listname.get(i);
					continue;
				}
			}
		}

		// 滑动监听
		select_pick.setOnSelectListener(new onSelectListener() {
			@Override
			public void onSelect(String text, int id) {
				// 选中的
				selectName = text;
				SelectID = id;
			}
		});

		shuerbtn.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				// 确定
				popu.dismiss();
				EmmApplication.setLog(root);
				Index_year_str2 = selectName;
				ed.setText(selectName);
			}
		});

		relative_all.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				// 点击事件消耗
			}
		});
	}

	/**
	 * <p>
	 * <b>Title：</b> 默认条件获取数据
	 * </p>
	 * <p>
	 * <b>Description：</b> 项目切换，刷新时，可以调用该方法
	 * </p>
	 *
	 * @author tangxin
	 * @date 2017年1月10日 下午2:07:10
	 */
	public void DefaultGetTimeConditionAnalysis() {
		Map<String, String> map = new HashMap<String, String>();

		if (IsSelectTime) {// 是否手动填写时间
			map.put("gradesTimeType", time_id);// 成绩时间类型
		} else {
			map.put("gradesStartTime", EmmApplication.replaceTime(Time_start_str));// 成绩开始时间
			map.put("gradesEndTime", EmmApplication.replaceTime(Time_end_str));// 成绩结束时间
		}
		if (IsSelectIndex) {// 是否手动填写月指标
			map.put("monthlyType", index_id);// 月指标类型
		} else {
			map.put("monthlyStartTime", EmmApplication.replaceTimeDay(Index_start_str));
			map.put("monthlyEndTime", EmmApplication.replaceTimeDay(Index_end_str));// 月指标结束时间
		}

		map.put("yearTime", EmmApplication.replace("年", "", selectName));// 年指标时间

		GetTimeConditionAnalysis(map);
	}

	/**
	 * <p>
	 * <b>Title：</b> 时间条件查询分析接口
	 * </p>
	 * <p>
	 * <b>Description：</b>
	 * </p>
	 *
	 * @param map
	 * @author tangxin
	 * @date 2017年1月10日 上午10:11:22
	 */
	private void GetTimeConditionAnalysis(Map<String, String> map) {
		EmmApplication.updateUrl("getTimeConditionAnalysis");
		map.put("token", EmmApplication.getToken());
		map.put("userId", EmmApplication.getUserId());
		map.put("projectCode", EmmApplication.getData(EmmApplication.ProjectCode));// 项目Code
		map.put("merchantId", EmmApplication.getData(EmmApplication.merchantId));// 商户ID
		map.put("version", EmmApplication.getPackageManager(5));
		map.put("terminalCode", EmmApplication.getPackageManager(2));
		Map<String, Object> paramsMap = new HashMap<String, Object>();
		paramsMap.put("params", map);
		JSONObject json = new JSONObject(paramsMap);
		String jsonstr = json.toString();
		RequestParams params = new RequestParams();
		params.put("body", jsonstr);
		Log.v(TAG, "getTimeConditionAnalysis___>post"+ EmmApplication.urlStr + "?body=" + jsonstr);
		AsyncHttpClient asyncHttpClient = new AsyncHttpClient();
		asyncHttpClient.post(EmmApplication.urlStr, params, new AsyncHttpResponseHandler() {
			@Override
			public void onFailure(Throwable error, String content) {
				super.onFailure(error, content);
				Loading.hideDialogForLoading();
				Log.v(TAG, "请求结束error:" + error + "==" + content);
			}

			@Override
			public void onFinish() {
				Loading.hideDialogForLoading();
				Log.v(TAG, "请求结束");
				super.onFinish();
			}

			@Override
			public void onStart() {
				super.onStart();
				Loading.showDialogForLoading(root, "加载中...", false, true, 60000);
				Log.v(TAG, "请求开始");
			}

			@Override
			public void onSuccess(String content) {
				super.onSuccess(content);
				if (content == null) {
					Log.v(TAG, "数据为空");
					return;
				}
				Log.v("日报数据请求成功", "content : " + content);
				JSONObject jsonObj = JSONObject.parseObject(content);
				JSONObject resData = (JSONObject) jsonObj.get("resData");
				if (resData == null) {
					Log.v(TAG, "登陆信息返回值为空");
					return;
				}
				GetTimeConditionAnalysis getTimeConditionAnalysis = JSONObject.parseObject(resData.toString(),
						GetTimeConditionAnalysis.class);
				if ("1".equals(getTimeConditionAnalysis.getResult())) {

					/* ↓--成绩--↓ */

					call_num.setText(getTimeConditionAnalysis.getCallNum());
					valid_call.setText(getTimeConditionAnalysis.getCallValidNum());
					visit_num.setText(getTimeConditionAnalysis.getVisitNum());
					newvisit_num.setText(getTimeConditionAnalysis.getFreshCusVisitNum());
					oldvisit_num.setText(getTimeConditionAnalysis.getOldCusVisitNum());
					from_num.setText(getTimeConditionAnalysis.getDepositNum());
					subscribe_Num.setText(getTimeConditionAnalysis.getSubscribeNum());
					subscribe_Amount.setText(getTimeConditionAnalysis.getSubscribeAmount());
					signed_num.setText(getTimeConditionAnalysis.getSignedNum());
					signed_amount.setText(getTimeConditionAnalysis.getSignedAmount());
					payment_amount.setText(getTimeConditionAnalysis.getPaymentAmount());

					/* ↑--成绩--↑ */

					/* ↓-月指标-↓ */

					monthlySalesRate.setText(SetRateString(getTimeConditionAnalysis.getMonthlySalesRate()));
					monthlySalesTarget.setText(SetTargetString(getTimeConditionAnalysis.getMonthlySalesTarget()));
					month_seekbar_index1.setProgress(Integer
							.valueOf(
									EmmApplication.drop4(EmmApplication.isNull(getTimeConditionAnalysis.getMonthlySalesRate()) ? getTimeConditionAnalysis
											.getMonthlySalesRate() : "0")).intValue());
					monthlyPaymentRate.setText(SetRateString(getTimeConditionAnalysis.getMonthlyPaymentRate()));
					monthlyPaymentTarget.setText(SetTargetString(getTimeConditionAnalysis.getMonthlyPaymentTarget()));
					month_seekbar_index2.setProgress(Integer
							.valueOf(
									EmmApplication.drop4(EmmApplication.isNull(getTimeConditionAnalysis
											.getMonthlyPaymentRate()) ? getTimeConditionAnalysis
											.getMonthlyPaymentRate() : "0")).intValue());
					monthlyGeneralRate.setText(SetRateString(getTimeConditionAnalysis.getMonthlyGeneralRate()));
					monthlyGeneralTarget.setText(SetTargetString(getTimeConditionAnalysis.getMonthlyGeneralTarget()));
					month_seekbar_index3.setProgress(Integer
							.valueOf(
									EmmApplication.drop4(EmmApplication.isNull(getTimeConditionAnalysis
											.getMonthlyGeneralRate()) ? getTimeConditionAnalysis
											.getMonthlyGeneralRate() : "0")).intValue());

					/* ↑-月指标-↑ */

					/* ↓-年指标-↓ */

					yearSalesRate.setText(SetRateString(getTimeConditionAnalysis.getYearSalesRate()));
					yearSalesTarget.setText(SetTargetString(getTimeConditionAnalysis.getYearSalesTarget()));
					seekbar_index1.setProgress(Integer
							.valueOf(
									EmmApplication.drop4("∞".equals(EmmApplication.isNull(getTimeConditionAnalysis
											.getYearSalesRate()) ? getTimeConditionAnalysis.getYearSalesRate() : "0") ? "100"
											: (EmmApplication.isNull(getTimeConditionAnalysis.getYearSalesRate()) ? getTimeConditionAnalysis
													.getYearSalesRate() : "0"))).intValue());
					yearPaymentRate.setText(SetRateString(getTimeConditionAnalysis.getYearPaymentRate()));
					yearPaymentTarget.setText(SetTargetString(getTimeConditionAnalysis.getYearPaymentTarget()));
					seekbar_index2.setProgress(Integer
							.valueOf(
									EmmApplication.drop4(EmmApplication.isNull(getTimeConditionAnalysis.getYearPaymentRate()) ? getTimeConditionAnalysis
											.getYearPaymentRate() : "0")).intValue());
					yearGeneralRate.setText(SetRateString(getTimeConditionAnalysis.getYearGeneralRate()));
					yearGeneralTarget.setText(SetTargetString(getTimeConditionAnalysis.getYearGeneralTarget()));
					seekbar_index3.setProgress(Integer
							.valueOf(
									EmmApplication.drop4(EmmApplication.isNull(getTimeConditionAnalysis.getYearGeneralRate()) ? getTimeConditionAnalysis
											.getYearGeneralRate() : "0")).intValue());

					/* ↑-年指标-↑ */

				} else {
					EmmApplication.T("" + getTimeConditionAnalysis.getErrorMsg().toString());
					Log.v("日报数据请求失败", "errorCode:" + getTimeConditionAnalysis.getErrorCode().toString() + "errorMsg:"
							+ getTimeConditionAnalysis.getErrorMsg().toString());
				}
			}
		});
	}

	private String SetRateString(String str) {
		return "(" + (EmmApplication.isNull(str) ? str : "0") + "%)";
	}

	private String SetTargetString(String str) {
		return "(" + (EmmApplication.isNull(str) ? str : "0/0") + "万)";
	}

}
